function fnFormatDetails ( oTable, nTr )
{
    var aData = oTable.fnGetData( nTr );
    var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;width:100%" >';
    sOut += "<tr><td>序号:</td><td>"+aData[1]+'</td></tr>';
    sOut += "<tr><td>ID:</td><td>"+aData[2]+'</td></tr>';
    sOut += '<tr><td>基站主:</td><td>'+aData[3]+'</td></tr>';
    sOut += '<tr><td>名称:</td><td>'+aData[4]+'</td></tr>';
    sOut += '<tr><td>地址:</td><td>'+aData[5]+'</td></tr>';
    sOut += '<tr><td>基站描述:</td><td>'+aData[6]+'</td></tr>';
    sOut += '<tr><td>红包口令:</td><td>'+aData[7]+'</td></tr>';
    sOut += '<tr><td>基站二维码:</td><td>'+aData[8]+'</td></tr>';
    sOut += "<tr><td>签到二维码:</td><td>"+aData[9]+'</td></tr>';
    sOut += "<tr><td>操作:</td><td>"+aData[10]+'</td></tr>';
    sOut += '</table>';
    return sOut;
}
/*
function fnFormatDetails ( oTable, nTr )
{
    var aData = oTable.fnGetData( nTr );
    var sOut = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">';
    sOut += '<tr><td>Rendering engine:</td><td>'+aData[1]+' '+aData[4]+'</td></tr>';
    sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
    sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
    sOut += '</table>';
    return sOut;
}
*/

$(document).ready(function() {
    $('#dynamic-table').dataTable( {
        //"aaSorting": [[ 2, "desc" ]]
    } );
    /*
     * Insert a 'details' column to the table
     */
    
    var nCloneTh = document.createElement( 'th' );
    var nCloneTd = document.createElement( 'td' );
    nCloneTd.innerHTML = '<span><img src="../style/images/details_open.png"  class="yincang" id="im"><label class="hidden-phone"></lable></span>';
  
    nCloneTh.innerHTML = "操作";
    nCloneTh.className = "bo";
    nCloneTd.className = "bo";
	
 
    $('#hidden-table-info thead tr').each( function () {
        this.insertBefore( nCloneTh, this.childNodes[0] );
    });

    $('#hidden-table-info tbody tr').each( function () {
        this.insertBefore(  nCloneTd.cloneNode( true ), this.childNodes[0] );
    });

    /*
     * Initialse DataTables, with no sorting on the 'details' column
     */
    var oTable = $('#hidden-table-info').dataTable( {
        "bInfo": false,//页脚信息
        "bPaginate" : false,
        "ordering":false,
        "bSort":false
    });

    /* Add event listener for opening and closing details
     * Note that the indicator for showing which row is open is not controlled by DataTables,
     * rather it is done here
     */
    $(function(){
    	$("span img").click(function(){
    		var nTr = $(this).parents('tr')[0];
    		if ( oTable.fnIsOpen(nTr) )
    		{
    			/* This row is already open - close it */
    			this.src = "../style/images/details_open.png";
    			oTable.fnClose( nTr );
    		}
    		else
    		{
    			/* Open this row */
    			this.src = "../style/images/details_close.png";
    			oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
    		}    		
    	});
    });
});